package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.dto.TjlResultDto;
import com.ruoyi.common.core.domain.entity.TjlResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.TjlResultMapper;
import com.ruoyi.system.service.ITjlResultService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @DATE : 2024/07/01 16:14
 */
@Service
public class TjlResultServiceImpl implements ITjlResultService {

    @Resource
    private TjlResultMapper mapper;

    @Override
    public List<TjlResult> list(TjlResultDto tjlResultDto) {
        List<String> startDate = tjlResultDto.getDateRange();
        String startTime = "";
        String endTime = "";
        if (startDate != null && !startDate.isEmpty() && !startDate.get(0).isEmpty()) {
            startTime = startDate.get(0);
            endTime = startDate.get(1);
            // 查询间隔
            String querySpace = tjlResultDto.getQuerySpace();
            Long querySpaceToLong = DateUtils.StrToNum(querySpace);
            return mapper.listByQuery(startTime, endTime, querySpaceToLong);
        } else {
            return mapper.list();
        }

    }
}
